﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/ezdesk_app_template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="pageTitle" -->
    <title>易得桌面</title>
    <!-- InstanceEndEditable -->
<link href="Content/jquery-ui.custom.css" rel="stylesheet" type="text/css" />
<link href="Content/ui.textbox.css" type="text/css" rel="stylesheet"  media="all" />
<link href="Content/freecontent.css" rel="stylesheet" type="text/css" />
<link href="Content/wdatepicker.css" rel="stylesheet" type="text/css" />
<link href="Content/ajaxbusy.css" rel="stylesheet" type="text/css" />
<link href="Content/Site.css" rel="stylesheet" type="text/css" />

<script src="Scripts/ezdesk_mockdata.js" type="text/javascript"></script>
<script src="Scripts/jquery.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui.custom.min.js" type="text/javascript"></script>   
<script src="Scripts/jquery.form.js" type="text/javascript"></script>
<script src="Scripts/ui.textbox.js" type="text/javascript"></script>
<script src="Scripts/pinyin.js" type="text/javascript"></script>
    <script src="Scripts/ezdesk-jquery-ui.js" type="text/javascript"></script>
    <script src="Scripts/ezdesk_common.js" type="text/javascript"></script>
</head>

<!-- InstanceBeginEditable name="pageStyles" -->
    <style type="text/css">
        .entryExplanation
        {
            font-weight: bolder;
            font-size: 14px;
            background-color: #FFEC8B;
        }
    </style>
    <!-- InstanceEndEditable -->
    
<!-- InstanceBeginEditable name="pageScripts" -->
<script type="text/javascript">
    //************* URL常量

    var URL_AUDIT_LEAVE = '/attendance/DoAuditLeave';

    //************* 全局变量

    var g_Var = {
        'leaveInfo': null
    };
    //************* 常量定义

    var StaticResource = {
        'isAgreed': '已通过审核',
        'isNotAgreed': '未通过审核'
    };
    //************* Accessor访问器

    var EzAccessor = {};
    if (ezmock.IS_MOCKED) {
        var mock_LeaveInfo =
        { "Id": "480f8836-29a9-4ba6- bbe1-8a3e928fc5de",
            "LeaveTypeId": "c7615898-2739-4c33-a8dc- a1451537b170",
            "LeaveTypeName": "外出",
            "User": {
                "Id": "ce36c495-38cc-4b7e- 875e-364ff8e087b5",
                "Name": "卢春叶",
                "UserName": "lcy",
                "Dept": {
                    "Id": "e8731583-3397-4f28-aa43-c006dbe750a2",
                    "DeptName": "行政部",
                    "GroupId": "c875149c-ee0c-48e2-bd2d- 39d870f49b67"
                }
            },
            "CreateTime": "1238413000",
            "StartTime": "1238463000",
            "EndTime": "1238468400",
            "Description": " 小东门银行",
            "IsAudited": false,
            "AuditUser": { "Name": "王晓" },
            "AuditNote": "asdasdasd",
            "AuditTime": "1282010290",
            "IsForWork": false,
            "IsAgreed": false
        };

        var mockEzAccessor = {
            'doUpdateAuditInfo': function () {
                var stateInfo = { 'State': 'Success', 'Info': '审核成功!', 'Data': null };
                $.displayStateInfo(stateInfo);
                bindAuditDetails();
            },
            'getBasicInfo': function () {
                g_Var['leaveInfo'] = mock_LeaveInfo;
            }
        };
        EzAccessor = mockEzAccessor;
    } else {
        var realEzAccessor = {
            'doUpdateAuditInfo': function (LeaveInfoId, AuditNote, IsAgree) {
                $(document).ajaxBusy('begin');

                //审核按钮disabled
                $('#btnAgree').button('option', 'disabled', true);
                $('#btnDisagree').button('option', 'disabled', true);

                //审核意见TEXT disabled
                $('#auditSuggestion').attr('disabled', true);
                //审核假期
                $.post(URL_AUDIT_LEAVE,
                   { "isAgreed": IsAgree, "leaveInfoId": LeaveInfoId, "auditNote": AuditNote },
                   function (e) {
                       $(document).ajaxBusy('end');
                       $.displayStateInfo(e);
                       //审核按钮
                       $('#btnAgree').button('option', 'disabled', false);
                       $('#btnDisagree').button('option', 'disabled', false);

                       //审核意见
                       $('#auditSuggestion').attr('disabled', false);

                       g_Var['leaveInfo'] = eval('(' + e.Data + ')');
                       bindAuditDetails();
                   });

            },
            'getBasicInfo': function () {
                //g_Var['leaveInfo'] = <%=ViewData["LeaveInfo"] %>;
            }
        };
        EzAccessor = realEzAccessor;
    }




    function toFullTimeFormat(dateTime) {

        var time = Date.fromEpoch(dateTime);
        var fullTime = time.toFullChineseDateFormat()
                       + " " + time.toFullTimeFormat();
        return fullTime;
    }

    function bindHeadTips() {

        var fullCreateTime = toFullTimeFormat(g_Var['leaveInfo']['CreateTime']);
        var temp = $('#department').html();
        var deptName = temp.replace("{deptName}", g_Var['leaveInfo']['User']['Dept']['DeptName']);

        $('#department').html(deptName);
        $('#applyName').html(g_Var['leaveInfo']['User']['Name']);
        $('#CreateTime').html(fullCreateTime);
        $('#applyLeaveType').html(g_Var['leaveInfo']['LeaveTypeName']);

    }

    function bindLeaveInfoDetails() {

        var fullStartTime = toFullTimeFormat(g_Var['leaveInfo']['StartTime']);
        var fullEndTime = toFullTimeFormat(g_Var['leaveInfo']['EndTime']);

        $('#lblApplyLeaveType').html(g_Var['leaveInfo']['LeaveTypeName']);
        $('#lblCreateTimeBegin').html(fullStartTime);
        $('#lblCreateTimeEnd').html(fullEndTime);
        $('#lblDescription').html(g_Var['leaveInfo']['Description']);

    }

    function bindAuditDetails() {

        if (g_Var['leaveInfo']["IsAudited"]) {

            var fullAuditTime = toFullTimeFormat(g_Var['leaveInfo']['AuditTime']);
            var auditer = g_Var['leaveInfo']['AuditUser']['Name'];
            var auditStatus = g_Var['leaveInfo']['IsAgreed'];
            var auditNote = g_Var['leaveInfo']['AuditNote'];

            $('#auditNewLeave').hide();
            $('#audited').show();

            $('#lblAuditer').html(auditer);
            $('#lblAuditTime').html(fullAuditTime);
            $('#lblAuditNote').html(auditNote);

            if (auditStatus) {
                $('#lblAuditStatus').html(StaticResource['isAgreed']);
            }
            else {

                $('#lblAuditStatus').html(StaticResource['isNotAgreed']);
            }
        }
        else {

            $('#auditNewLeave').show();
            $('#audited').hide();
        }

    }



    function doIsAgreed(isAgree) {

        var LeaveInfoId = g_Var['leaveInfo']['Id'];

        g_Var['leaveInfo']['IsAudited'] = true;
        g_Var['leaveInfo']['IsAgreed'] = isAgree;

        g_Var['leaveInfo']['AuditNote'] = $('#auditSuggestion').val().htmlEncode();

        EzAccessor.doUpdateAuditInfo(LeaveInfoId, g_Var['leaveInfo']['AuditNote'], g_Var['leaveInfo']['IsAgreed']);


    }

    function initPage() {
        EzTipsManager.addTipBox('#tip_Remind', 'tipRemind');
        EzTipsManager.showTipBox('tipRemind');

        EzAccessor.getBasicInfo();

        bindHeadTips();
        bindLeaveInfoDetails();
        bindAuditDetails();
    }


    function initPageEvent() {
        $('#btnAgree').click(function () {

            doIsAgreed(true);

            $('.page-submit').hide();
        });
        $('#btnDisagree').click(function () {

            doIsAgreed(false);

            $('.page-submit').hide();
        });

    }


    $(function () {
        initPage();
        initPageEvent();
    });
</script>
<!-- InstanceEndEditable -->



<body>
<div id="root">
	<div id="headw">
    	<div id="head">
            <!-- InstanceBeginEditable name="pageHead" -->
			<p>
                早上好，杨裕欣(软件工程部)
		    </p>
            <div id="status-bar">
            <span><a href="#">设置</a></span>&nbsp;
            魏玛软件出品
            </div>
            <div id="tabs">
				<ul>
					<li><a class="current">第一栏</a></li>
					<li><a>第一栏</a></li>
					<li><a>第一栏</a></li>
				</ul>
			</div>
            <!-- InstanceEndEditable -->
        </div>
    </div>
    <div id="main">
    
    	<div id="contentw">
            <div id="content-page">
	            <!-- InstanceBeginEditable name="pageContent" -->
                    <div id="page-head">
                        <span id="applyName"></span><span id="department">({deptName})</span> <span id="CreateTime">
                        </span>提交假期申请
                    </div>
                    <div id="page-body">
                        <ul class="fieldslist">
                            <li>
                                <div class="l">
                                    <label>
                                        请假类别:</label>
                                </div>
                                <div class="r">
                                    <label id="lblApplyLeaveType" style="margin-left: 10px;">
                                    </label>
                                </div>
                            </li>
                            <li>
                                <div class="l">
                                    <label>
                                        开始时间:</label>
                                </div>
                                <div class="r">
                                    <label id="lblCreateTimeBegin" style="margin-left: 10px;">
                                    </label>
                                </div>
                            </li>
                            <li>
                                <div class="l">
                                    <label>
                                        结束时间:</label>
                                </div>
                                <div>
                                    <label id="lblCreateTimeEnd" style="margin-left: 10px;">
                                    </label>
                                </div>
                            </li>
                            <li>
                                <div class="l">
                                    <label>
                                        原因描述:</label>
                                </div>
                                <div class="r">
                                    <label id="lblDescription" disabled="disabled" style="margin-left: 10px;">
                                    </label>
                                </div>
                            </li>
                        </ul>
                        <div id="auditNewLeave">
                            <div class="formBox" style="margin: 20px 0 0 0;">
                                <div>
                                    <span class="entryExplanation">填写审核意见</span> <span>如果不填写将置空。</span>
                                </div>
                                <textarea id="auditSuggestion" cols="30" rows="4" style="margin-left: 10px;"></textarea>
                            </div>
                        </div>
                        <ul class="fieldslist" id="audited" style="display: none; margin: 20px 0 0 0;">
                            <li>
                                <div>
                                    <ul>
                                        <li>
                                            <div class="l">
                                                <label>
                                                    审核状态:</label>
                                            </div>
                                            <div class="r">
                                                <label id="lblAuditStatus" style="margin-left: 10px;">
                                                </label>
                                            </div>
                                        </li>
                                        <li>
                                            <div class="l">
                                                <label>
                                                    审核人:</label>
                                            </div>
                                            <div class="r">
                                                <label id="lblAuditer" style="margin-left: 10px;">
                                                </label>
                                            </div>
                                        </li>
                                        <li>
                                            <div class="l">
                                                <label>
                                                    审核时间:</label>
                                            </div>
                                            <div class="r">
                                                <label id="lblAuditTime" style="margin-left: 10px;">
                                                </label>
                                            </div>
                                        </li>
                                        <li>
                                            <div class="l">
                                                <label>
                                                    审核意见:</label>
                                            </div>
                                            <div class="r">
                                                <label id="lblAuditNote" style="margin-left: 10px;">
                                                </label>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <div class="page-submit">
                        <input id="btnAgree" type="button" value="同意" style="margin-left: 20px;" />
                        或者 <a id="btnDisagree">拒绝</a>
                    </div>
            <!-- InstanceEndEditable -->
            </div>
            <div id="content-foot"><small>这个是内容下面的脚注</small></div>
        </div>        
        
        <div id="tipsw">
	        <!-- InstanceBeginEditable name="pageShortcut" -->
            <!-- InstanceEndEditable -->            
            
            <div id="tips" class="box">
           	
            </div>
        </div>
        <div class="clearfloat"></div>
    </div> 
</div>
	    <!-- InstanceBeginEditable name="pageFoot" -->
    <div id="tip_Remind" style="display: none;">
        <h1>
            小贴士:</h1>
        <p class="indent">
        </p>
    </div>
    <!-- InstanceEndEditable -->    
</body>
<!-- InstanceEnd --></html>
